import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const Layout = () => import('../views/Layout.vue')
const Home = () => import('../views/Home.vue')
const Cate = () => import('../views/Cate.vue')
const Cart = () => import('../views/Cart.vue')
const My = () => import('../views/My.vue')
const Register = () => import('../views/Register.vue')
const Login = () => import('../views/Login.vue')

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '', // 默认的子路由
        component: Home
      },
      {
        path: 'cate', // 缩写形式，只写子路由，不写父路由
        component: Cate
      },
      {
        path: '/cart', // 完整的子路由：父路由+子路由
        component: Cart
      },
      {
        path: 'my',
        component: My
      },
    ]
  },
  {
    path: '/register',
    component: Register
  },
  {
    path: '/Login',
    component: Login
  },
  // 404页面的配置
]

const router = new VueRouter({
  mode: 'history',
  // base: 'u-shop',
  routes
})

export default router
